import 'dart:convert';

void main() {
  var list = List<Grade>.empty(growable: true);
  list.add(Grade("A", [ClassGrade("A1"), ClassGrade("A2")]));
  list.add(Grade("B", [ClassGrade("B1"), ClassGrade("B2")]));
  list.add(Grade("C", [ClassGrade("C1"), ClassGrade("C2")]));
  var jsonString = """{"name": "John Smith", "email": "john@example.com"}""";
  Map<String, dynamic> user = jsonDecode(jsonString);

  print('Howdy, ${user['name']}!');
  print('We sent the verification link to ${user['email']}.');


  Map<String, dynamic> userMap = jsonDecode(jsonString);
  var user1 = User.fromJson(userMap);

  print('Howdy, ${user1.name}!');
  print('We sent the verification link to ${user1.email}.');


  String json = jsonEncode(user);
  print(json);
}

// user.dart
class User {
  final String name;
  final String email;

  User(this.name, this.email);

  User.fromJson(Map<String, dynamic> json)
      : name = json['name'],
        email = json['email'];

  Map<String, dynamic> toJson() => {
    'name': name,
    'email': email,
  };
}

class Grade {
  String name;
  List<ClassGrade> grade;

  Grade(this.name, this.grade);
}

class ClassGrade {
  String name;

  ClassGrade(this.name);
}
